package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.ChannelMapper;
import com.lune.job.pojo.Channel;
import com.lune.job.pojo.ResPageBean;
import com.lune.job.service.IChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class ChannelServiceImpl extends ServiceImpl<ChannelMapper, Channel> implements IChannelService {

    @Autowired
    private ChannelMapper channelMapper;

    /**
     * 分页查询栏目
     * @param currentPage
     * @param size
     * @param channel
     * @return
     */
    @Override
    public ResPageBean queryPage(Integer currentPage, Integer size, Channel channel) {
        Page<Channel> page = new Page<>(currentPage, size);
        IPage<Channel> channelIPage = channelMapper.queryPage(page,channel);
        ResPageBean resPageBean = new ResPageBean(channelIPage.getTotal(), channelIPage.getPages(), channelIPage.getRecords());
        return  resPageBean;
    }

    @Override
    public List<Channel> tree(Channel channel) {
        return channelMapper.queryCon(channel);
    }

    /**
     * 条件查询栏目
     * @param channel
     * @return
     */
    @Override
    public List<Channel> queryByCon(Channel channel) {
        return channelMapper.queryCon(channel);
    }


}
